$(document).ready(function() {

    var passengers = 0;
    var oiltype = "";
    var transmission = "";
    var drive = "";
    var bed = 0;
    var sortid = 6;
    var orderid = 2;
    var city = "深圳";
    var startDate = "";
    var endDate = ""; //全局变量
    var page = 1; //分页数
    /*let starttime=decodeURI(getQueryString("starttime"));
    let backtime=decodeURI(getQueryString("backtime"));*/
    /*decodeURI可以解码: 将 %20 转换成 空格
    encodeURI可以编码: 将 空格 转换成 %20*/
    /*var rentstarttime=window.localStorage.getItem("rentstarttime");
    var rentbacktime=window.localStorage.getItem("rentbacktime");*/
    PageLoadTime();
    load();
    sy();
    cityjs();
    tran();
    oilt();
    driv();
    passe();
    bedN();
    salesV();
    sales();
    carP();
    getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
    wantCity(1);
    setCity();
    clickcity();
    ChooseRentTime();
    CountRentTime();
    chooseCar();


    //计算出发返程时间差
    function CountRentTime() {
        var startdate = $("input#chooseGotime").val();
        var enddate = $("input#chooseBacktime").val();
        var starthour = $("input#chooseGohour").val();
        var endhour = $("input#chooseBackhour").val();
        startdate = startdate.replace(/-/g, "/");
        enddate = enddate.replace(/-/g, "/");
        var sd = startdate + " " + starthour + ":00";
        var ed = enddate + " " + endhour + ":00";
        //处理时间
        var stime = new Date(sd);
        var etime = new Date(ed);
        var usedTime = etime - stime;
        var days = Math.floor(usedTime / (24 * 3600 * 1000));
        //计算出小时数  
        var leave1 = usedTime % (24 * 3600 * 1000); //计算天数后剩余的毫秒数  
        var hours = Math.floor(leave1 / (3600 * 1000));
        //计算相差分钟数  
        var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数  
        var minutes = Math.floor(leave2 / (60 * 1000));

        var up = days + "天";
        var down = hours + "小时" + minutes + "分钟";
        var counttime = up + down;
        $("div.rentlist_choose_right_time_behind").text(counttime);

    }
    //时间处理函数
    function exchangeTime(time) {
        var a = time.split(" ")[0];
        var b = parseInt(a.split("-")[1]); //取出时间月的部分
        var c = parseInt(a.split("-")[2]); //取出时间日的部分
        var d = a.split("-")[0] //取出时间年部分，为String
        if (b <= 9) {
            b = "0" + b
        }
        if (c <= 9) {
            c = "0" + c
        }
        var e = d + "-" + b + "-" + c;
        return e;
    }
    //根据参数请求车辆列表
    function getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page) {
        imgb = basePath + "/static/pcsofangche/rent/rentlist/";
        console.log("city为" + city);
        console.log("startDate为" + startDate);
        console.log("endDate为" + endDate);
        console.log("passengers为" + passengers);
        console.log("oiltype为" + oiltype);
        console.log("transmission为" + transmission);
        console.log("drive为" + drive);
        console.log("bed为" + bed);
        console.log("sortid为" + sortid);
        console.log("orderid为" + orderid);
        //清空上次的数据
        $("div.rentlist_content_right_down").html("");
        $("div.rentlist_content_right_page_center").html("");
        //设置title
        $(document).attr("title", city + "房车租赁列表"); //修改title值
        $.ajax({
            dataType: "json",
            type: "post",
            data: {
                city: city,
                startDate: startDate,
                endDate: endDate,
                passengers: passengers,
                oiltype: oiltype,
                transmission: transmission,
                drive: drive,
                bed: bed,
                sortid: sortid,
                orderid: orderid,
                page: page
            },
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            url: basePath + "/car/searchbypage",
            success: function(data) {
                console.log('data=' + data.data);
                var s = "";
                var p = "";
                var le = "";
                if (data.data == "") {
                    layer.msg("找不到您想要的信息，试试其他条件搜索吧！");
                    p = p + "<div class=\"rentlist_content_right_down_itemimg\"><img src=\"" + imgb + "img/listerror.png" + "\" class=\"rentlist_content_right_down_itemimg_posi\" /></div>"
                    $("div.rentlist_content_right_page_center").html(p);
                } else {
                    for (var i = 0; i < data.data.length; i++) {
                        le = data.data[i].totalpage;
                        ex = data.data[i].exinfo;
                        console.log("ex=" + ex);
                        var exi = "";
                        if (ex != null && ex != "" && ex != undefined) {
                            exi = "<div class=\"rentlist_content_right_down_item_center_infofive clearfix\">\n" +
                                "<div class=\"rentlist_content_right_down_item_center_infofive_icon\">\n" +
                                "<img src=\"" + imgb + "img/icon_sale_small.png" + "\" class=\"rentlist_content_right_down_item_center_infofive_icon_posi\" />\n" +
                                "</div>\n" +
                                "<div class=\"rentlist_content_right_down_item_center_infofive_word\">" + ex + "</div>\n" +
                                "</div>"
                        };
                        s = s +
                            "<div class=\"rentlist_content_right_down_item row\">\n" +
                            "<div class=\"col-lg-3 col-md-3 rentlist_content_right_down_item_icon\">\n" +
                            "<img src=\"" + data.data[i].img + "\" alt=\"carpicture\" class=\"img-responsive rentlist_content_right_down_item_icon_posi\" />\n" +
                            "</div>\n" +
                            "<div class=\"col-lg-5 col-md-5 rentlist_content_right_down_item_center\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_title\">" + data.data[i].title + "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_icon\"><img src=\"" + imgb + "img/rentlist_icon_hezairengshu25.18.jpg\" alt=\"\" class=\"rentlist_content_right_down_item_center_infoone_item_icon_posi\" /></div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_info\">" + data.data[i].passengers + "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_icon\"><img src=\"" + imgb + "img/rentlist_icon_youhao23.24.jpg\" alt=\"\" class=\"rentlist_content_right_down_item_center_infoone_item_icon_posi\" /></div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_info\">" + data.data[i].oilwear + "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_icon\"><img src=\"" + imgb + "img/rentlist_icon_biansuqi19.25.jpg\" alt=\"\" class=\"rentlist_content_right_down_item_center_infoone_item_icon_posi\" /></div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_info\">" + data.data[i].transmission + "</div>\n" +
                            "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infotwo clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_icon\"><img src=\"" + imgb + "img/rentlist_icon_ranyou21.25.jpg\" alt=\"\" class=\"rentlist_content_right_down_item_center_infoone_item_icon_posi\" /></div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_info\">" + data.data[i].oiltype + "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_icon\"><img src=\"" + imgb + "img/rentlist_icon_cheliangpinpai25.16.jpg\" alt=\"\" class=\"rentlist_content_right_down_item_center_infoone_item_icon_posi\" /></div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_info\">" + data.data[i].license + "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_icon\"><img src=\"" + imgb + "img/rentlist_icon_liangqu25.25.jpg\" alt=\"\" class=\"rentlist_content_right_down_item_center_infoone_item_icon_posi\" /></div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_info\">" + data.data[i].drive + "</div>\n" +
                            "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infothree clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_icon\"><img src=\"" + imgb + "img/rentlist_icon_chuangwei25.20.jpg\" alt=\"\" class=\"rentlist_content_right_down_item_center_infoone_item_icon_posi\" /></div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_item_info\">" + data.data[i].bed + "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infoone_bed\">" + data.data[i].bedinfo + "</div>\n" +
                            "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infofour\">\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infofour_city\">\n" +
                            "<img src=\"" + imgb + "img/rentlist_icon_pick.png\" class=\"rentlist_content_right_down_item_center_infofour_city_posi\" />\n" +
                            "<div class=\"rentlist_content_right_down_item_center_infofour_detail\">" + data.data[i].city + "</div>\n" +
                            "</div>\n" +

                            "<div class=\"rentlist_content_right_down_item_center_infofour_moredetail\">" + data.data[i].pickinfo + "</div>\n" +
                            "</div>\n" +
                            exi +
                            "</div>\n" +
                            "<div class=\"col-lg-2 col-md-2 rentlist_content_right_down_item_price\">\n" +
                            "<div class=\"rentlist_content_right_down_item_price_content clearfix\">\n" +
                            "<div class=\"rentlist_content_right_down_item_price_content_three\">起</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_price_content_two\">" + data.data[i].price + "</div>\n" +
                            "<div class=\"rentlist_content_right_down_item_price_content_one\">¥</div>\n" +
                            "</div>\n" +
                            "</div>\n" +
                            "<div class=\"col-lg-2 col-md-2 rentlist_content_right_down_item_b\">\n" +
                            "<input type=\"button\" value=\"租车\" class=\"normalb rentlist_content_right_down_item_b_posi pull-right\" data-rentcarid = \"0\"/>\n" +
                            "<font class=\"hidden\">" + data.data[i].id + "</font>" +
                            "</div>\n" +
                            "\n" +
                            "</div>";
                    };
                    for (var i = 1; i <= le; i++) {
                        p = p + "<div class=\"rentlist_content_right_page_center_item shand\">" + i + "</div>"
                    };
                    $("div.rentlist_content_right_down").html(s);
                    $("div.rentlist_content_right_page_center").html(p);
                    //只有在生成结构之后才能对结构进行绑定事件
                    infoGoto(); //
                    WantinfoByPage();
                }

            },
            error: function() {
                console.log("访问失败");
            },
            complete: function() {
                console.log("请求完成");
                layer.close(LoadingIcon);
            },
        });
    }
    //绑定跳转详情页事件
    function infoGoto() {
        var x = $("input.rentlist_content_right_down_item_b_posi").length;
        for (var i = 0; i < x; i++) {
            $("input.rentlist_content_right_down_item_b_posi:eq(" + i + ")").click(function(i) {
                return function() {
                    var carid = $("div.rentlist_content_right_down_item_b:eq(" + i + ")>font").text();
                    var rentcity = $("input#chooseGocity").val();
                    var startDate = $("input#chooseGotime").val();
                    var endDate = $("input#chooseBacktime").val();
                    var starthour = $("input.rentlist_choose_left_item_three:eq(0)").val();
                    var endhour = $("input.rentlist_choose_left_item_three:eq(1)").val();
                    var test = TestGoToList();
                    if (test == 1) {
                        var url = basePath + "/rentinfo?rentcity=" + rentcity + "&startDate=" + startDate + "&endDate=" + endDate + "&carid=" + carid + "&starthour=" + starthour + "&endhour=" + endhour;
                        url = encodeURI(url);
                        url = encodeURI(url);
                        window.location.href = (url);
                    };
                }
            }(i));
        };
    }
    //绑定点击页数请求事件
    function WantinfoByPage() {
        var l = $("div.rentlist_content_right_page_center_item").length;
        for (var i = 0; i < l; i++) {
            $("div.rentlist_content_right_page_center_item:eq(" + i + ")").click(function(i) {
                return function() {
                    page = $("div.rentlist_content_right_page_center_item:eq(" + i + ")").text();
                    getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page);
                }
            }(i))
        }
    }
    //初始化及同步城市，时间信息
    function sy() {
        city = $("input#chooseGocity").val();
        startDate = $("input#chooseGotime").val();
        endDate = $("input#chooseBacktime").val();
    }
    //初始化，字体颜色变化
    function load() {
        $(".rentlist_content_left_item:eq(0)>.rentlist_content_left_item_item:eq(0)").addClass("rentlist_content_left_item_itemchoose");
        $(".rentlist_content_left_item:eq(1)>.rentlist_content_left_item_item:eq(0)").addClass("rentlist_content_left_item_itemchoose");
        $(".rentlist_content_left_item:eq(2)>.rentlist_content_left_item_item:eq(0)").addClass("rentlist_content_left_item_itemchoose");
        $(".rentlist_content_left_item:eq(3)>.rentlist_content_left_item_item:eq(0)").addClass("rentlist_content_left_item_itemchoose");
        $(".rentlist_content_left_item:eq(4)>.rentlist_content_left_item_item:eq(0)").addClass("rentlist_content_left_item_itemchoose");
        $(".rentlist_content_right_up_item:eq(0)").addClass("rentlist_content_right_up_itemchoose");
    }
    //选择城市绑定事件
    function cityjs() {
        $("#chooseGocity").focus(function() {
            $(".rentlist_choose_left_item_city").removeClass("hidden");
            $(".rentlist_choose_left_item_city").focus();
        }); //选择城市得到焦点触发
        $("#chooseBackcity").focus(function() {
            $(".rentlist_choose_left_item_city").removeClass("hidden");
            $(".rentlist_choose_left_item_city").focus();
        }); //选择城市得到焦点触发

        if (CustomerBrowser == "IE") {
            $(".rentlist_choose_left_item_city").mouseleave(function() {
                $(".rentlist_choose_left_item_city").addClass("hidden");
            }); //选择城市失去焦点触发
        } else if (CustomerBrowser == "Safari") {
            $(".rentlist_choose_left_item_city").mouseleave(function() {
                $(".rentlist_choose_left_item_city").addClass("hidden");
            }); //选择城市失去焦点触发
        } else {
            $(".rentlist_choose_left_item_city").blur(function() {
                $(".rentlist_choose_left_item_city").addClass("hidden");
            }); //选择城市失去焦点触发
        }

    }
    //选择变速器选项做出请求
    function tran() {
        for (var i = 0; i <= 2; i++) {
            $(".rentlist_content_left_item:eq(0)>.rentlist_content_left_item_item:eq(" + i + ")").click(function(i) {
                return function() {
                    $(".rentlist_content_left_item:eq(0)>.rentlist_content_left_item_item").removeClass("rentlist_content_left_item_itemchoose");
                    $(this).addClass("rentlist_content_left_item_itemchoose");
                    transmission = $(".rentlist_content_left_item:eq(0)>font:eq(" + i + ")").text();
                    console.log("transmission值为" + transmission);
                    sy();

                    getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)

                }
            }(i));
        } //选择变速器选项做出请求
    }
    //选择燃油类型选项做出请求
    function oilt() {
        for (var i = 0; i <= 2; i++) {
            $(".rentlist_content_left_item:eq(1)>.rentlist_content_left_item_item:eq(" + i + ")").click(function(i) {
                return function() {
                    $(".rentlist_content_left_item:eq(1)>.rentlist_content_left_item_item").removeClass("rentlist_content_left_item_itemchoose");
                    $(this).addClass("rentlist_content_left_item_itemchoose");
                    oiltype = $(".rentlist_content_left_item:eq(1)>font:eq(" + i + ")").text();
                    console.log("oiltype值为" + oiltype);
                    sy();

                    getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
                }
            }(i));
        } //选择燃油类型选项做出请求
    }
    //选择燃油类型选项做出请求
    function driv() {
        for (var i = 0; i <= 2; i++) {
            $(".rentlist_content_left_item:eq(2)>.rentlist_content_left_item_item:eq(" + i + ")").click(function(i) {
                return function() {
                    $(".rentlist_content_left_item:eq(2)>.rentlist_content_left_item_item").removeClass("rentlist_content_left_item_itemchoose");
                    $(this).addClass("rentlist_content_left_item_itemchoose");
                    drive = $(".rentlist_content_left_item:eq(2)>font:eq(" + i + ")").text();
                    console.log("drive值为" + drive);
                    sy();
                    getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
                }
            }(i));
        } //选择燃油类型选项做出请求
    }
    //选择荷载人数类型选项做出请求
    function passe() {
        for (var i = 0; i <= 4; i++) {
            $(".rentlist_content_left_item:eq(3)>.rentlist_content_left_item_item:eq(" + i + ")").click(function(i) {
                return function() {
                    $(".rentlist_content_left_item:eq(3)>.rentlist_content_left_item_item").removeClass("rentlist_content_left_item_itemchoose");
                    $(this).addClass("rentlist_content_left_item_itemchoose");
                    passengers = $(".rentlist_content_left_item:eq(3)>font:eq(" + i + ")").text();
                    console.log("passengers值为" + passengers);
                    sy();
                    getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
                }
            }(i));
        } //选择荷载人数类型选项做出请求
    }
    //选择床位数量选项做出请求
    function bedN() {
        for (var i = 0; i <= 5; i++) {
            $(".rentlist_content_left_item:eq(4)>.rentlist_content_left_item_item:eq(" + i + ")").click(function(i) {
                return function() {
                    $(".rentlist_content_left_item:eq(4)>.rentlist_content_left_item_item").removeClass("rentlist_content_left_item_itemchoose");
                    $(this).addClass("rentlist_content_left_item_itemchoose");
                    bed = $(".rentlist_content_left_item:eq(4)>font:eq(" + i + ")").text();
                    console.log("bed值为" + bed);
                    sy();
                    getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
                }
            }(i));
        } //选择床位数量选项做出请求
    }
    //选择综合排序选项做出请求
    function salesV() {
        $("div.rentlist_content_right_up_item:eq(0)").click(function() {
            $(".rentlist_content_right_up div").removeClass("rentlist_content_right_up_itemchoose");
            $(this).addClass("rentlist_content_right_up_itemchoose");
            sortid = 6
            // console.log("sortid值为" + sortid);
            sy();
            getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
        }) //选择综合排序选项做出请求
    }
    //选择销量选项做出请求
    function sales() {
        var orderid = 1
        $(".rentlist_content_right_up_item:eq(1)").click(function() {
            $(".rentlist_content_right_up div").removeClass("rentlist_content_right_up_itemchoose");
            $(this).addClass("rentlist_content_right_up_itemchoose");
            sy();
            sortid = 1
            if ( orderid == 2 ){
                orderid = 1;
                $(this).addClass('asc').removeClass('desc')
                getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page) 
            }else {
                orderid = 2;
                $(this).addClass('desc').removeClass('asc')
                getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
            }
           
        }) //选择销量选项做出请求
    }
    //选择价格选项做出请求
    function carP() {
        var orderid = 1
        $(".rentlist_content_right_up_item:eq(2)").click(function() {
            $(".rentlist_content_right_up div").removeClass("rentlist_content_right_up_itemchoose");
            $(this).addClass("rentlist_content_right_up_itemchoose");
            sortid = 3
            if ( orderid == 2) {
                orderid = 1;
                $(this).addClass('asc').removeClass('desc')
                getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
            } else {
                orderid = 2;
                $(this).addClass('desc').removeClass('asc')
                getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page)
            }
        });
    }
    //首页banner中房车租赁城市请求
    function wantCity(type) {
        $
            .ajax({
                dataType: "json",
                type: "post",
                url: basePath + "/carsearch",
                data: {
                    type: type
                },
                contentType: "application/x-www-form-urlencoded;charset=utf-8",

                success: function(data) {
                    var s = "";
                    for (var i = 0; i < data.data.length; i++) {
                        s = s + "<div class=\"index_choosemode_one_right_city_down_item\">" + data.data[i].city + "</div>" +
                            "<font class=\"hidden\">" + data.data[i].city + "</font>"

                    };;
                    $("div.index_choosemode_one_right_city_down").html(s);
                    setCity(); //只有在生成结构之后才能对结构进行绑定事件
                },
                error: function() {
                    console.log("访问失败");
                },
                complete: function() {

                },
            });
    }
    //绑定banner城市选择点击事件
    function setCity() {
        var len = $("div.index_choosemode_one_right_city_down_item").length;
        for (var i = 0; i < len; i++) {
            $("div.index_choosemode_one_right_city_down_item:eq(" + i + ")").click(function(i) {
                return function() {
                    var city = $("div.index_choosemode_one_right_city_down>font:eq(" + i + ")").text();
                    $("input#chooseGocity").val(city);
                    $("input#chooseBackcity").val(city);
                    $("div.rentlist_choose_left_item_city").addClass("hidden");
                }
            }(i))
        }
    }
    //绑定banner选择多少城市点击事件
    function clickcity() {
        for (var i = 0; i < 6; i++) {
            $("div.index_choosemode_one_right_city_up_three_item:eq(" + i + ")").click(function(i) {
                return function() {
                    var type = i + 1;
                    wantCity(type);
                }
            }(i));
        }
    }
    //绑定立即选车事件
    function chooseCar() {
        $("input.rentlist_choose_right_b").click(function() {
            sy();
            var test = TestGoToList();
            if (test === 1) {
                getCarlist(city, startDate, endDate, passengers, oiltype, transmission, drive, bed, sortid, orderid, page);
            }
        });
    }
    //初始化出发时间返程时间
    function PageLoadTime() {
        $.ajax({
            dataType: "json",
            type: "post",
            url: basePath + "/indexFormaltime",
            data: {

            },

            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            success: function(data) {
                var start = data.data.start;
                var end = data.data.end;
                var test = $("input#chooseGotime").val();
                var time = $("input.rentlist_choose_left_item_three:eq(0)").val();
                if (test == "") {
                    $("input#chooseGotime").val(start);
                    $("input#chooseBacktime").val(end);
                }
                if (time == "") {
                    $("input.rentlist_choose_left_item_three:eq(0)").val("09:00");
                    $("input.rentlist_choose_left_item_three:eq(1)").val("09:00");
                }
            },
            error: function() {
                console.log("访问失败");
            },
            complete: function() {
                console.log("请求完成");
            },
        });
    }
    //选择时间模式
    function ChooseRentTime() {
        laydate.render({
            elem: '#chooseGotime', //指定元素,
            min: new Date().Format("yyyy-MM-dd")
        });
        laydate.render({
            elem: '#chooseBacktime', //指定元素,
            min: new Date().Format("yyyy-MM-dd")
        });
        $("input.rentlist_choose_left_item_three:eq(0)").focus(function() {
            $("div.rentlist_choosetimestart").removeClass("hidden");
            $("div.rentlist_choosetimestart").focus();
            $("div.rentlist_choosetimeend").addClass("hidden");
        });
        //绑定选择出发时间事件
        for (var i = 0; i < 48; i++) {
            $("div.rentlist_choosetimestart div.index_choosemode_one_right_timechoose_right_item:eq(" + i + ")").click(function(i) {
                return function() {
                    var time = $(this).text();
                    //					starthour = $(this).data("time");
                    $("input.rentlist_choose_left_item_three:eq(0)").val(time);
                    $("div.rentlist_choosetimestart").addClass("hidden");
                    CountRentTime();
                }
            }(i))
        };

        $("input.rentlist_choose_left_item_three:eq(1)").focus(function() {
            $("div.rentlist_choosetimeend").removeClass("hidden");
            $("div.rentlist_choosetimeend").focus();
            $("div.rentlist_choosetimestart").addClass("hidden");
        });
        //绑定选择返回时间事件
        for (var i = 0; i < 48; i++) {
            $("div.rentlist_choosetimeend div.index_choosemode_one_right_timechoose_right_item:eq(" + i + ")").click(function(i) {
                return function() {
                    var etime = $(this).text();
                    //					endhour = $(this).data("time");
                    $("input.rentlist_choose_left_item_three:eq(1)").val(etime);
                    $("div.rentlist_choosetimeend").addClass("hidden");
                    CountRentTime();
                }
            }(i))
        };

        if (CustomerBrowser == "IE") {
            $("div.rentlist_choosetimeend").mouseleave(function() {
                $(this).addClass("hidden");
                CountRentTime();
            });
            $("div.rentlist_choosetimestart").mouseleave(function() {
                $(this).addClass("hidden");
                CountRentTime();
            });
        } else if (CustomerBrowser == "Safari") {
            $("div.rentlist_choosetimeend").mouseleave(function() {
                $(this).addClass("hidden");
                CountRentTime();
            });
            $("div.rentlist_choosetimestart").mouseleave(function() {
                $(this).addClass("hidden");
                CountRentTime();
            });
        } else {
            $("div.rentlist_choosetimeend").blur(function() {
                $(this).addClass("hidden");
                CountRentTime();
            });
            $("div.rentlist_choosetimestart").blur(function() {
                $(this).addClass("hidden");
                CountRentTime();
            });
        }

        $("div.rentlist_choose").mouseenter(function() {
            CountRentTime();
        });
        $("div.rentlist_content").mouseenter(function() {
            CountRentTime();
        });

    }
    //是否可以跳转判定
    function TestGoToList() {
        var startdate = $("input#chooseGotime").val();
        var enddate = $("input#chooseBacktime").val();
        var starttime = $("input#chooseGohour").val();
        var endtime = $("input#chooseBackhour").val();
        startdate = startdate.replace(/-/g, "/");
        enddate = enddate.replace(/-/g, "/");
        var start = startdate + " " + starttime + ":00";
        var end = enddate + " " + endtime + ":00";
        var sd = new Date(start);
        var ed = new Date(end);
        var now = new Date();
        console.log("start=" + start);
        console.log("sd=" + sd);
        console.log("end=" + end);
        console.log("ed=" + ed);
        if (sd >= ed) {
            alert("选择开始时间不能大于结束时间！");
            return (0);
        };
        if (sd <= now) {
            alert("选择开始时间不能小于现在时间！")
            return (0)
        };
        return (1);
    }

});